<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>添加页面</title>
    <script src="/html/js/axios.min.js"></script>
    <script src="/html/js/ajax.js"></script>
</head>
<script>

    window.onload = function () {
        findDept();
    }

    /**
     * 查找部门
     */
    async function findDept() {
        let info = await ajaxGet("/dept/findAll");
        let str = "";
        for (let i = 0; i < info.length; i++) {
            let obj = info[i];
            str += `<option value="${obj.deptId}">${obj.deptName}</option>`;
        }
        $("deptSelect").innerHTML = str;
    }

    async function add() {
        let params = {
            employeeName: $("employeeName").value,
            employeeBirthday: $("employeeBirthday").value,
            money: $("money").value,
            deptId: $("deptSelect").value
        }

        let info = await ajaxGet("/employee/add", params);
        //服务器返回ok表示成功
        console.log(info)
        location.href = "/html/index.html";
    }
</script>


<body>
姓名 <input type="text" id="employeeName">
生日 <input type="date" id="employeeBirthday">
工资 <input type="number" id="money">
部门 <select name="deptSelect" id="deptSelect"></select>
<input type="submit" value="点击提交" onclick="add()">

</body>
</html>